|
| Contents | |
| About This Extension |
The Group Volume extension provides methods for conveniently adjusting the overall volume of an entire group of Music Object instances. This, for example, makes it really easy for the overall group volume levels of all Music Object instances that are being used for one functional aspect of a page's sonification (such as user interface sound effects or background music) to be adjusted in one simple step, without interfering with the different instances' individual volume levels that are being used to balance the instances together in the group. In particular, this extension offers the Music.setPageVolume and Music.getPageVolume static methods that make it possible to modify the overall volume of a page's sonification in one operation.
| What's New in the Latest Version |
There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.
| Getting This Extension |
To get the "music-object-x-group-volume.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-group-volume.js" into an appropriate folder of the local copy of your Web site.
In case you have problems saving the file using the above link, the "music-object-x-group-volume.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.
| Dependencies |
In order to use this extension, the following JavaScript file(s) must first be sourced in...
For more information on using extensions, consult the section About Music Object Extensions.
| Reference |
| |||||||||||||||||||||||
| Static Methods |
| Music.addVolumeGroupMembers |
|
The Music.addVolumeGroupMembers static method lets you add the specified Music Object instances as members to the specified volume group
|
Music.addVolumeGroupMembers ( GroupNameSTR , GroupMembersARRAYorOBJ ) |
Multiple Music Object instances can be added to a group - one at a time - by specifying the Music Object instance references in multiple calls to the Music.addVolumeGroupMembers method, as in the code...
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject3);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject4);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject5);
|
Alternatively, by specifying an array for the GroupMembersARRAYorOBJ parameter, all the instances can be added in just one statement. A temporary array can be created inside the call to the Music.addVolumeGroupMembers method to contain all the Music Object instances, as in the code...
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
When adding members to a volume group, it doesn't matter in what order the members are added, over how many separate statements the members are added, or whether the members are added using arrays or single object references.
So, for example, the code...
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject5,
myMusicObject3,
myMusicObject4
)
);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);
|
...is equivalent to the code...
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
It also does not matter how many times a specific Music Object instance is added to a volume group. Any Music Object instance can only be a member of a group once. So, the following code still results in only five members being added to the volume group "My Volume Group"...
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject3);
|
When no GroupMembersARRAYorOBJ parameter is specified, then all Music Object instances currently created in the document will be added to the specified volume group.
When there is also no GroupNameSTR parameter specified, then the value "Page Volume" will be used as the default for this parameter.
| Music.destroyVolumeGroup |
|
The Music.destroyVolumeGroup static method lets you destroy the specified volume group, effectively removing all of its members.
| Music.destroyVolumeGroup ( GroupNameSTR ) |
The volume setting for a volume group that is being destroyed will cease to have any effect on the Music Object instances that belonged to the group, so there may be a noticeable volume change for those instances at the time that a volume group is destroyed.
Removing all of the members of a volume group has the same effect as destroying the volume group. For instance, a volume group that was set up with the code...
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
...could be destroyed with the code...
Music.removeVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
...or the code...
Music.destroyVolumeGroup ('My Volume Group');
|
When no GroupNameSTR parameter is specified, then the value "Page Volume" will be used as the default for this parameter.
| Music.fadeGroupVolume |
|
The Music.fadeGroupVolume static method lets you perform a volume fade on the specified volume group.
|
Music.fadeGroupVolume ( GroupNameSTR , StartVolume0to100 , EndVolume0to100 , FadeTimeMsINT , FadeEndCallbackFunctionorJavaScriptSTR , ) |
| FadeOBJ |
When no FadeEndCallback parameter is specified, then no callback will be executed when the fade reaches its conclusion.
When there is also no FadeTimeMsINT parameter specified, then the fade will have a default duration of 1 second (1000ms), which is equivalent to specifying the value 1000 for this parameter.
When there is also no EndVolume0to100 parameter specified, then the fade will have a default end volume of 0 (silence).
When there is also no StartVolume0to100 parameter specified, then the fade will start at the current volume level of the specified volume group.
When there is also no GroupNameSTR parameter specified, then the value "Page Volume" will be used as the default for this parameter.
| Music.fadePageVolume |
|
The Music.fadePageVolume static method lets you perform a fade of the page's volume, effectively fading all Music Object instances in the page.
|
Music.fadePageVolume ( StartVolume0to100 , EndVolume0to100 , FadeTimeMsINT , FadeEndCallbackFunctionorJavaScriptSTR , ) |
| FadeOBJ |
The Music.fadePageVolume method essentially performs a fade for the special volume group "Page Volume", which contains all Music Object instances in a page.
When no FadeEndCallback parameter is specified, then no callback will be executed when the fade reaches its conclusion.
When there is also no FadeTimeMsINT parameter specified, then the fade will have a default duration of 1 second (1000ms), which is equivalent to specifying the value 1000 for this parameter.
When there is also no EndVolume0to100 parameter specified, then the fade will have a default end volume of 0 (silence).
When there is also no StartVolume0to100 parameter specified, then the fade will start at the current volume level of the specified volume group.
| Music.getGroupVolume |
|
The Music.getGroupVolume static method returns an integer value, indicating the volume level for the specified volume group.
| Music.getGroupVolume ( GroupNameSTR ) |
| Volume0to100 |
When no GroupNameSTR parameter is specified, then the value "Page Volume" will be used as the default for this parameter. Using this variation is, in effect, equivalent to using the Music.getPageVolume method.
| Music.getPageVolume |
|
The Music.getPageVolume static method returns an integer value, indicating the overall volume level for the page.
| Music.getPageVolume ( ) |
| Volume0to100 |
The Music.getPageVolume method essentially queries the volume level for the special volume group "Page Volume", which contains all Music Object instances in a page.
| Music.removeVolumeGroupMembers |
|
The Music.removeVolumeGroupMembers static method lets you remove the specified Music Object instance(s) from the specified volume group.
|
Music.removeVolumeGroupMembers ( GroupNameSTR , GroupMembersARRAYorOBJ ) |
Multiple Music Object instances can be removed from a group - one at a time - by specifying the Music Object instance references in multiple calls to the Music.removeVolumeGroupMembers method, as in the code...
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject1);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject3);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject4);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject5);
|
Alternatively, by specifying an array for the GroupMembersARRAYorOBJ parameter, all the instances can be removed in just one statement. A temporary array can be created inside the call to the Music.removeVolumeGroupMembers method to contain all the Music Object instances, as in the code...
Music.removeVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
When removing members from a volume group, it doesn't matter in what order the members were originally added, over how many separate statements the members were added, or whether the members were added using arrays or single object references.
So, for example, the members added to the volume group "My Volume Group" using the code...
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject5,
myMusicObject3,
myMusicObject4
)
);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);
|
...could all be removed from the volume group "My Volume Group" using the single statement...
Music.removeVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
Removing all of the members of a volume group has the same effect as destroying the volume group. For instance, a volume group that was set up with the code...
Music.addVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
...could be destroyed with the code...
Music.removeVolumeGroupMembers (
'My Volume Group',
new Array (
myMusicObject1,
myMusicObject2,
myMusicObject3,
myMusicObject4,
myMusicObject5
)
);
|
...or the code...
Music.destroyVolumeGroup ('My Volume Group');
|
When no GroupMembersARRAYorOBJ parameter is specified, then all Music Object instances currently created in the document will be removed from the specified volume group.
When there is also no GroupNameSTR parameter specified, then the value "Page Volume" will be used as the default for this parameter.
| Music.setGroupVolume |
|
The Music.setGroupVolume static method lets you set the volume level for the specified volume group.
| Music.setGroupVolume ( GroupNameSTR , Volume0to100 ) |
When the value -1 is specified in place of the Volume0to100 parameter, then the volume group specified by the GroupNameSTR parameter will effectively be removed. If there is no existing volume group matching the name specified by the GroupNameSTR parameter, then the Music.getGroupVolume method will have no effect.
| Music.setPageVolume |
|
The Music.setPageVolume static method lets you set the overall page volume, affecting all Music Object instances in the page.
| Music.setPageVolume ( Volume0to100 ) |
The Music.setPageVolume method essentially sets the volume level for the special volume group "Page Volume", which contains all Music Object instances in a page.
When the value -1 is specified in place of the Volume0to100 parameter, then the "Page Volume" volume group will effectively be removed. This would have a similar effect to using the statement